package org.lalib.controller.form;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;

import org.lalib.acquire.IControllerForm;
import org.lalib.entity.object.EFood;
import org.lalib.entity.object.EOrder;
import org.lalib.entity.object.ETable;
import org.lalib.entity.object.EUser;
import org.springframework.stereotype.Controller;

@SessionScoped
@Controller("cWaiterForm")
public class CWaiterForm implements IControllerForm {

	private static final long serialVersionUID = 1L;

	private Double total = (double) 0;
	private EUser user;
	private EOrder currentOrder;
	private ETable selectedTable;
	private List<EFood> foods = new ArrayList<>();
	private List<ETable> tables = new ArrayList<>();
	private List<EOrder> ordersForTable = new ArrayList<>();
	private List<SelectItem> foodSelectItems = new ArrayList<>();
	private List<SummaryBean> summaryBeans = new ArrayList<>();

	private Long selectedFood;
	private String description = "";

	public List<ETable> getTables() {
		return tables;
	}

	public void setTables(List<ETable> tables) {
		this.tables = tables;
	}

	public EUser getUser() {
		return user;
	}

	public void setUser(EUser user) {
		this.user = user;
	}

	public ETable getSelectedTable() {
		return selectedTable;
	}

	public void setSelectedTable(ETable selectedTable) {
		this.selectedTable = selectedTable;
	}

	public List<EOrder> getOrdersForTable() {
		return ordersForTable;
	}

	public void setOrdersForTable(List<EOrder> ordersForTable) {
		this.ordersForTable = ordersForTable;
	}

	public List<EFood> getFoods() {
		return foods;
	}

	public void setFoods(List<EFood> foods) {
		this.foods = foods;
	}

	public List<SelectItem> getFoodSelectItems() {
		return foodSelectItems;
	}

	public void setFoodSelectItems(List<SelectItem> foodSelectItems) {
		this.foodSelectItems = foodSelectItems;
	}

	public Long getSelectedFood() {
		return selectedFood;
	}

	public void setSelectedFood(Long selectedFood) {
		this.selectedFood = selectedFood;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public EOrder getCurrentOrder() {
		return currentOrder;
	}

	public void setCurrentOrder(EOrder currentOrder) {
		this.currentOrder = currentOrder;
	}

	public List<SummaryBean> getSummaryBeans() {
		return summaryBeans;
	}

	public void setSummaryBeans(List<SummaryBean> summaryBeans) {
		this.summaryBeans = summaryBeans;
	}

	public Double getTotal() {
		return total;
	}

	public void setTotal(Double total) {
		this.total = total;
	}

	public class SummaryBean {

		public SummaryBean(String foodName, Double total, Long orderId) {
			setFoodName(foodName);
			setTotal(total);
			setOrderId(orderId);
		}

		private String foodName = "";
		private Long orderId;
		private Double total = (double) 0;
		private boolean selected = true;

		public String getFoodName() {
			return foodName;
		}

		public void setFoodName(String foodName) {
			this.foodName = foodName;
		}

		public boolean isSelected() {
			return selected;
		}

		public void setSelected(boolean selected) {
			this.selected = selected;
		}

		public Double getTotal() {
			return total;
		}

		public void setTotal(Double total) {
			this.total = total;
		}

		public Long getOrderId() {
			return orderId;
		}

		public void setOrderId(Long orderId) {
			this.orderId = orderId;
		}
	}
}